# encoding=utf-8
'''
admin工作原理:

1、预加载:
项目执行settings-->
urls.py ( admin.autodiscover() ) -- >
settings.py ( INSTALL APPS(each app) ) -->
(app下包含) admin.py -- >
admin.py 执行其代码

2、处理admin.py:
如果在项目app下存在admin.py(app对应的根路径) 则会加载其中代码。
'''
# 默认管理管理工具
# admin.site.register(Entity);
# 自定义管理工具

from django.contrib import admin

from orm.crawler import QQCategory
from orm.models import Entity, RingWeb, SystemConfig


class EntityAdmin(admin.ModelAdmin):
    list_play = ('id', 'key', 'val')  # 页面展示的字段和对应次序
    search_fields = ('id', 'key')  # 页面搜索框
    list_filter = ('val',)  # 过滤器
admin.site.register(Entity, EntityAdmin);

class RingWebAdmin(admin.ModelAdmin):
    list_play = ('id', 'name', 'artist', 'duration', 'status')
    search_fields = ('id', 'name', 'artist')
    list_filter = ('status',)
admin.site.register(RingWeb, RingWebAdmin);

class SystemConfigAdmin(admin.ModelAdmin):
    list_play = ('name', 'value')
    search_fields = ('name', 'value')
admin.site.register(SystemConfig, SystemConfigAdmin);

class QQCategoryAdmin(admin.ModelAdmin):
    list_play = ('id', 'name', 'g_name','exts')
    search_fields = ('name', 'g_name', )
    list_filter = ('name','g_name')
admin.site.register(QQCategory, QQCategoryAdmin);

